import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:yp/config/config.dart';

import 'logic.dart';
import 'state.dart';

class GongDansPage extends StatelessWidget {
  final GongDansLogic logic = Get.put(GongDansLogic());
  final GongDansState state = Get.find<GongDansLogic>().state;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Config.mainColor,
        title: Text(
          "服务进度",
          style: TextStyle(
            color: Colors.white,
            fontSize: 34.sp,
          ),
        ),
        centerTitle: true,
        elevation: 0,
      ),
      body: GetBuilder<GongDansLogic>(
        builder: (logic) {
          return state.orderList != null && state.orderList.length == 0
              ? Container(
                  child: Center(
                    child: Text("系统未找到该外部单号或销售单号相关工单"),
                  ),
                )
              : state.orderList == null
                  ? Container()
                  :
          Container(
              alignment: Alignment.topLeft ,
          padding: EdgeInsets.only(top:0,left:20,right:20,bottom:30,) ,
          child:
          ListView.builder(
                      itemBuilder: (ctx, i) {
                        var item = state.orderList[i];
                        return
                          Container(
                              alignment: Alignment.topLeft ,
                              padding: EdgeInsets.only(top:30,
                               // left:20,right:20,bottom:30,
                              ) ,
                              child:
                            Column(
                                mainAxisAlignment: MainAxisAlignment.start,
                                children:[
                              Container(
                                alignment: Alignment.topLeft ,
                                padding: EdgeInsets.only(bottom:10,
                                  // left:20,right:20,bottom:30,
                                ) ,
                                child: Text(item["title"],
                                  style:TextStyle(fontSize: 18),
                                ),
                              ),

                              Container(
                                padding: EdgeInsets.only(bottom:5,
                                  // left:20,right:20,bottom:30,
                                ) ,
                                child: Text(item["content"]),
                              ),
                          Row(
                          mainAxisAlignment: MainAxisAlignment.spaceAround,

                          children: [
                            Text(
                                item["operationMan"],
                              style:TextStyle(
                                  fontSize: 14,
                                  color:Colors.grey),
                              ),
                            Text(
                              item["operationDate"],
                              style:TextStyle(
                                  fontSize: 14,
                                  color:Colors.grey),
                            ),

                        ],
                        )
                        ]
                        )
                          )
                        ;
                      },
                      itemCount: state.orderList.length,
                    )
          );
        },
      ),
    );
  }
}
